package homework;

public class Work5 {
    public static void main(String[] args) {
        Account account1 = new Account();
        account1.print();
        Account account2=new Account();
        account2.print();

        account1.overage=10000;
        account1.allBalance(5,Account.interestRate);
        account2.overage=50000;
        account2.allBalance(5,Account.interestRate);

    }
}

class  Account{
    int ID;
    static int count=10001;
    String password="000000";
    double overage;
    static double interestRate=0.003;
    {
        ID=count++;
    }

    //计算本息后余额
    public void allBalance(int year,double interestRate){
        double sum=0;
        sum=this.overage*Math.pow((1+interestRate),year);
        System.out.println("本息合计为： "+sum);
    }

    //打印属性
    public void print(){
        System.out.println("account ID: "+this.ID+"  password: "+this.password+
                "  account balance: "+this.overage+"  year interest rate"+Account.interestRate);
    }

    public Account() {
    }

    public Account(String password, double overage) {
        this.password = password;
        this.overage = overage;
    }
}
